package com.duyj.server.account.dao;

import com.duyj.client.account.model.Account;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

@Repository
public interface AccountDAO {

    @Update("update tp_account set amount = amount - #{amount} where name = #{name}")
    void updateAccount(Account account);


    @Insert("insert into tp_account(name, amount) values(#{name}, #{amount})")
    void insertAccount(Account account);

    @Select("select amount from tp_account where name = #{code}")
    BigDecimal getAccountAmount(String name);
}
